﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QueueUnlimited.API
{
    public class Subscriber
    {
        public string Name { get; private set; }
        private List<string> eventNames = new List<string>();

        public Subscriber(string name)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            Name = name;
        }

        public Subscriber(string name, string eventName)
            : this(name)
        {
            eventNames.Add(eventName);
        }

        public void AddEvent(string eventName)
        {
            if (!eventNames.Contains(eventName))
                eventNames.Add(eventName);
        }
        public void AddEvents(params string[] eventNames)
        {
            if (eventNames != null)
                foreach (var eventName in eventNames)
                    AddEvent(eventName);
        }

        internal IEnumerable<string> EventNames()
        {
            return eventNames.AsEnumerable();
        }

        public void RemoveEvent(string eventName)
        {
            eventNames.RemoveAll(x => string.Equals(x, eventName));
        }
    }
}
